@radio-prefix-cls: ~"@{css-prefix}radio";
@radio-group-prefix-cls: ~"@{radio-prefix-cls}-group";
@radio-inner-prefix-cls: ~"@{radio-prefix-cls}-inner";
@radio-group-button-prefix-cls: ~"@{radio-group-prefix-cls}-button";

.@{radio-prefix-cls}-focus {
  // box-shadow: 0 0 0 2px fade(@color-brand-primary, 20%);
  z-index: 1;
}

.@{radio-group-prefix-cls} {
  display: inline-block;
  font-size: @font-size-base;
  vertical-align: middle;

  //outline: none;
  &-vertical {
    .@{radio-prefix-cls}-wrapper {
      display: block;
      height: 30px;
      line-height: 30px;
    }
  }
}

// 普通状态 - Normal state
.@{radio-prefix-cls}-wrapper {
  font-size: @font-size-base;
  vertical-align: middle;
  display: inline-block;
  position: relative;
  white-space: nowrap;
  margin-right: 8px;
  cursor: pointer;

  &-disabled {
    cursor: @cursor-disabled;
  }

  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }

    .@{radio-prefix-cls}-disabled {
      .@{radio-inner-prefix-cls} {
        border-color: @color-border-normal1;
      }
    }
  }

  //outline: none;
}

.@{radio-prefix-cls} {
  display: inline-block;
  margin-right: 10px;
  white-space: nowrap;
  //outline: none;
  position: relative;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;

  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }
  }

  &-inner {
    display: inline-block;
    width: 14px;
    height: 14px;
    position: relative;
    top: 0;
    left: 0;
    background-color: @color-bg-card;
    border: 1px solid @color-border-normal1;
    border-radius: 50%;
    transition: all @transition-time @ease-in-out;

    &:after {
      position: absolute;
      width: 6px;
      height: 6px;
      left: 3px;
      top: 3px;
      border-radius: @border-radius-base;
      display: table;
      border-top: 0;
      border-left: 0;
      content: ' ';
      background-color: @color-functional-white;
      opacity: 0;
      transition: all @transition-time @ease-in-out;
      transform: scale(0);
    }
  }

  &-large {
    font-size: @font-size-base;

    & .@{radio-inner-prefix-cls} {
      width: 14px;
      height: 14px;

      &:after {
        width: 6px;
        height: 6px;
        left: 3px;
        top: 3px;
      }
    }

    &.@{radio-prefix-cls}-wrapper,
    & .@{radio-prefix-cls}-wrapper {
      font-size: @font-size-base;
    }
  }

  &-small {
    & .@{radio-inner-prefix-cls} {
      width: 14px;
      height: 14px;

      &:after {
        width: 6px;
        height: 6px;
        left: 3px;
        top: 3px;
      }
    }
  }

  &-input {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    opacity: 0;
    cursor: pointer;
  }

  &-border {
    border: 1px solid @color-border-normal1;
    border-radius: @border-radius-base;
    height: @btn-height-base;
    line-height: @btn-height-base - 2px;
    padding: 0 15px;
    transition: border @transition-time @ease-in-out;
  }

  &-small&-border,
  .@{radio-group-prefix-cls}-small &-border {
    height: @btn-height-small;
    line-height: @btn-height-small - 2px;
    padding: @btn-padding-small;
  }

  &-large&-border,
  .@{radio-group-prefix-cls}-large &-border {
    height: @btn-height-base;
    line-height: @btn-height-base - 4px;
    padding: @btn-padding-base;
  }
}

.@{radio-prefix-cls}-wrapper-checked.@{radio-prefix-cls}-border {
  border-color: @color-brand-primary;
}

.@{radio-prefix-cls}-wrapper-disabled.@{radio-prefix-cls}-border {
  border-color: @color-border-disable;
}

// 选中状态 - Selected state
.@{radio-prefix-cls}-checked {
  .@{radio-inner-prefix-cls} {
    border-color: @color-brand-primary;
    background-color: @color-bg-radio-checked;

    &:after {
      opacity: 1;
      transform: scale(1);
      transition: all @transition-time @ease-in-out;
      background-color: @color-bg-radio-selected;
    }
  }

  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }
  }
}

.@{radio-prefix-cls}-disabled {
  cursor: @cursor-disabled;

  .@{radio-prefix-cls}-input {
    cursor: @cursor-disabled;
  }

  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @color-border-normal1;
    }
  }

  .@{radio-inner-prefix-cls} {
    // border-color: @color-border-normal1;
    // &:after {
    //     background-color: #cccccc;
    // }
    border-color: @color-border-normal1;
    background-color: @color-bg-disable;
    &:after {
      background-color: @color-complementary-7;
    }
  }

  .@{radio-prefix-cls}-disabled+span {
    color: @color-text-disabled;
  }

  &.@{radio-prefix-cls}-checked .@{radio-inner-prefix-cls} {
    background-color: @color-bg-disable;
  }
}

span.@{radio-prefix-cls}+* {
  margin-left: 2px;
  margin-right: 2px;
}

// 按钮样式 - Button style
.@{radio-group-button-prefix-cls} {
  font-size: 0;
  -webkit-text-size-adjust: none;

  .@{radio-prefix-cls} {
    width: 0;
    margin-right: 0;
  }

  .@{radio-prefix-cls}-wrapper {
    display: inline-block;
    height: @btn-circle-size;
    line-height: @btn-circle-size - 2px;
    margin: 0;
    padding: 0 16px - 1px;
    font-size: @font-size-base;
    color: @color-text-level3;
    transition: all @transition-time ease-in-out;
    cursor: pointer;
    border: 1px solid @color-border-normal1;
    border-left: 0;
    background:@color-bg-card;
    position: relative;

    >span {
      margin-left: 0;
    }

    &:before,
    &:after {
      content: '';
      display: block;
      position: absolute;
      width: 1px;
      height: 100%;
      left: -1px;
      top: 0;
      background: @color-border-normal1;
      //visibility: hidden;
      transition: all @transition-time ease-in-out;
    }

    &:after {
      height: @btn-circle-size + 4px;
      left: -1px;
      top: -3px;
      background: fade(@color-brand-primary, 20%);
      opacity: 0;
    }

    &:first-child {
      border-radius: @border-radius-base 0 0 @border-radius-base;
      border-left: 1px solid @color-border-normal1;

      &:before,
      &:after {
        display: none;
      }
    }

    &:last-child {
      border-radius: 0 @border-radius-base @border-radius-base 0;
    }

    &:first-child:last-child {
      border-radius: @border-radius-base;
    }

    &:hover {
      position: relative;
      color: @color-brand-primary;

      & .@{radio-prefix-cls} {
        background-color: black;
      }
    }

    .@{radio-prefix-cls}-inner,
    input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    &-checked {
      background-color: @color-bg-nomal;
      border-color: @color-brand-primary;
      color: @color-brand-primary;
      box-shadow: -1px 0 0 0 @color-brand-primary;
      z-index: 1;

      &:before {
        background: @color-brand-primary;
        opacity: 0.1;
      }

      &.@{radio-prefix-cls}-focus {

        // box-shadow: -1px 0 0 0 @color-brand-primary, 0 0 0 2px fade(@color-brand-primary, 20%);
        // transition: all @transition-time ease-in-out;
        &:after {
          // left: -3px;
          // top: -3px;
          // opacity: 1;
          // background: fade(@color-brand-primary, 20%);
        }

        &:first-child {
          // box-shadow: 0 0 0 2px fade(@color-brand-primary, 20%);
        }
      }

      &:first-child {
        border-color: @color-brand-primary;
        box-shadow: none;
      }

      &:hover {
        border-color: tint(@color-brand-primary, 20%);
        //box-shadow: -1px 0 0 0 tint(@color-brand-primary, 20%);
        // color: tint(@color-brand-primary, 20%);
      }

      &:active {
        border-color: shade(@color-brand-primary, 5%);
        //box-shadow: -1px 0 0 0 shade(@color-brand-primary, 5%);
        color: shade(@color-brand-primary, 5%);
      }
    }

    &-disabled {
      border-color: @color-border-normal1;
      background-color: @color-bg-page;
      cursor: @cursor-disabled;
      color: @color-text-disabled;

      &:first-child,
      &:hover {
        border-color: @color-border-normal1;
        background-color: @color-bg-page;
        color: @color-text-disabled;
      }

      &:first-child {
        border-left-color: @color-border-normal1;
      }
    }

    &-disabled.@{radio-prefix-cls}-wrapper-checked {
      color: @color-functional-white;
      background-color: @color-brand-disabled2;
      border-color: @color-border-normal1;
      box-shadow: none !important;
    }
  }

  &-solid .@{radio-prefix-cls}-wrapper {
    &-checked:not(.@{radio-prefix-cls}-wrapper-disabled) {
      background: @color-brand-primary;
      color: @color-functional-white;

      &:hover {
        background: tint(@color-brand-primary, 20%);
        color: @color-functional-white;
      }
    }
  }
}

.@{radio-group-button-prefix-cls}.@{radio-group-prefix-cls}-large .@{radio-prefix-cls}-wrapper {
  height: @btn-circle-size-large;
  line-height: @btn-circle-size-large - 2px;
  font-size: @font-size-base;

  &:after {
    height: @btn-circle-size-large + 4px;
  }
}

.@{radio-group-button-prefix-cls}.@{radio-group-prefix-cls}-small .@{radio-prefix-cls}-wrapper {
  height: @btn-circle-size-small;
  line-height: @btn-circle-size-small - 2px;
  padding: 0 12px;
  font-size: @font-size-base;

  &:after {
    height: @btn-circle-size-small + 4px;
  }

  &:first-child {
    border-radius: @border-radius-base 0 0 @border-radius-base;
  }

  &:last-child {
    border-radius: 0 @border-radius-base @border-radius-base 0;
  }
}